home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 4
/
The 640 Meg Shareware Studio CD-ROM Volume IV (Data Express)(1994).ISO
/
clang
/
cenvid.zip
/
DELTREE1.BAT
< prev
next >
Wrap
DOS Batch File
|
1993-06-24
|
2KB
|
64 lines
@echo off
REM DelTree1 - Delete a directory, including all files and subdirectories. This is
REM slower than DelTree2, because it deletes one file at a time.
if "%1"=="" GOTO SHOW_HOW
:This is a dangerious function, so make sure they really want it
ECHO THIS WILL DELETE ALL FILES AND DIRECTORIES UNDER %1
ECHO %1 MUST BE A VALID DIRECTORY AND YOU NEED MSDOS 5
CEnvi GetUKey.cmm ARE YOU SURE YOU WANT TO DO THIS? (Y/N) yn
if N==%UKEY% GOTO FINI
:Check that it is a valid file name
CEnvi ValidDir.bat %1 COMPLAIN
if ERRORLEVEL 1 GOTO FINI
:Unset attributes so that all files can be deleted
attrib -H -S -R %1\*.* /s > NUL
:Delete each name in the directory and sub-directories
dir %1 /A-d /f /s /On | cenvi #include '%0,bat,:DelFiles'
:DelFiles while ( NULL != (FileName = gets()) ) {
:DelFiles printf("DEL %s\n",FileName)
:DelFiles remove(FileName)
:DelFiles }
: Remove each directory, in reverse sorted order. To do this will dump the
: directories into a temporary file, and revers sort that file.
dir %1 /Ad /f /s > %1\DelTree1.tmp
sort /R < %1\DelTree1.tmp > %1\DelTree2.tmp
set TEMP_DIRS=%1\DelTree2.tmp
cenvi #include '%0,bat,:RemDirs'
:RemDirs if ( NULL == (fp = fopen(TEMP_DIRS,"r")) )
:RemDirs printf("\aERROR OPENING FILE")
:RemDirs else {
:RemDirs while ( NULL != (DirName = fgets(fp)) ) {
:RemDirs if ( DirName[strlen(DirName)-1] == '\n' )
:RemDirs DirName[strlen(DirName)-1] = 0
:RemDirs if ( DirName[strlen(DirName)-1] != '.' ) {
:RemDirs sprintf(Command,"RMDIR %s",DirName);
:RemDirs printf("%s\n",Command)
:RemDirs system(Command)
:RemDirs }
:RemDirs }
:RemDirs fclose(fp)
:RemDirs }
set TEMP_DIRS=
del %1\DelTree?.tmp
:Finally, delete the directory itself
ECHO RMDIR %1
rmdir %1 > NUL
GOTO FINI
:SHOW_HOW
ECHO
ECHO DelTree1.bat - Delete this directory and all files and subdirectories within it.
ECHO
GOTO FINI
:FINI
set UKEY=